[Unit]
Description=MySQL Server
Documentation=man:mysqld($version)
Documentation=http://dev.mysql.com/doc/refman/en/using-systemd.html
After=network.target
After=syslog.target
[Install]
WantedBy=multi-user.target
Alias=mysql.service

[Service]
User=${user}
Group=${user}

Type=forking

#systemctl status就是根据pid来判断服务的运行状态的
PIDFile=${pidfile}
# 以root权限来启动程序
PermissionsStartOnly=true
# 设置程序启动前的必要操作。例如初始化相关目录等等
ExecStartPre=${basedir}/sh/mysql_clean_sock.sh
# 启动服务
## --daemonize $MYSQLD_OPTS
ExecStart=${basedir}/bin/mysqld --defaults-file=/etc/my.cnf --daemonize

# Don't signal startup success before a ping works
#ExecStartPost=/usr/bin/mysql-systemd-start post
# Give up if ping don't get an answer
TimeoutSec=600
#Restart配置可以在进程被kill掉之后,让systemctl产生新的进程,避免服务挂掉
Restart=on-failure
RestartPreventExitStatus=1
PrivateTmp=false

# Use this to switch malloc implementation
# EnvironmentFile=-/etc/sysconfig/mysql
# Sets open_files_limit
# LimitNOFILE = 5000
